<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // 数组
    let arr = [1, 2, 3, 4, 5];
    // 查
    document.write(arr[0]+'<br>');
    // 改
    arr[1] = 22; //[1,22,3,4,5]
    document.write(arr+'<br>');
    // 增
    // push:在数组末尾添加一个元素,返回新数组的长度
    let newLength = arr.push(6); 
    document.write('长度:'+newLength+'<br>' +'数组:'+ arr + '<br>'); //6,[1,22,3,4,5,6]
    // unshift:在数组开头添加一个元素,返回新数组的长度
    let newLength2 = arr.unshift(0); //[0,1,22,3,4,5,6]
    document.write('长度:'+newLength2+'<br>' +'数组:'+ arr + '<br>');
    // 删
    // pop:在数组末尾删除一个元素,返回被删除的元素
    let data = arr.pop(); //[0,1,22,3,4,5]
    document.write('删除的元素:'+data+'<br>' +'数组:'+ arr + '<br>');
    // shift:在数组开头删除一个元素,返回被删除的元素
    let data2 = arr.shift(); //[1,22,3,4,5]
    document.write('删除的元素:'+data2+'<br>' +'数组:'+ arr + '<br>');
    // splice:删除指定元素，splice(index,num),返回被删除的元素
    let data3 = arr.splice(1,2); //[1,4,5]
    document.write('删除的元素:'+data3+'<br>' +'数组:'+ arr + '<br>');
    let data4 = arr.splice(1) 
    document.write('删除的元素:'+data4+'<br>' +'数组:'+ arr + '<br>');
   
    
    
  </script>
</body>
</html>